import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:nft_shop/box/conteroller/Invite_box_controller.dart';
import 'package:nft_shop/box/model/models.dart';
import 'package:nft_shop/res/global.dart';
import 'package:nft_shop/widgets/load_image.dart';
import 'package:share/share.dart';

class DialogGainBox extends StatelessWidget {
  InviteUserList model;
  DialogGainBox({Key? key,required this.model}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final Widget content = Material(
        color: Colors.transparent,
        child: Column(
          children: [
            Container(
              width: double.infinity,
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(5),
                  border: Border.all(color: Color(0xFFC6B395), width: 1),
                  color: Global.kTheme.textPrimary4
              ),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Padding(
                    padding: const EdgeInsets.only(top: 17),
                    child: Text("恭喜您获得",style: TextStyle(fontSize: 18,color:Color(0xFFF2CAA6),),),
                  ),
                  SizedBox(height: 5,),
                  Text(model.title??"",style: TextStyle(fontSize: 30,color:Color(0xFFF2CAA6),),),
                  Padding(
                    padding: const EdgeInsets.only(top: 20),
                    child: ClipRRect(borderRadius: BorderRadius.circular(23),child:
                    LoadImage(model.url??"",width: Get.width- 160 - 50,height: Get.width- 160 - 50,fit: BoxFit.fitHeight,)),
                  ),
                  InkWell(
                    onTap: (){
                      Share.share(
                          InviteBoxController.to.infoModel!.url??"${Global.AppHost + "download"}",
                          subject: Global.AppName);
                    },
                    child: Container(
                      margin: EdgeInsets.only(top: 24,bottom: 10),
                      padding: EdgeInsets.symmetric(horizontal: 35,vertical: 10),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(100),
                        gradient: LinearGradient(colors: [
                          Color(0xFFF7D39D),
                          Color(0xFFFDC360),
                        ], begin: Alignment.centerLeft, end: Alignment.centerRight),
                      ),
                      child: Text("分享拆盲盒",style: TextStyle(fontSize: 18,color: Color(0xFFA74706)),),
                    ),
                  ),
                  Text("拆盲盒机会剩余${InviteBoxController.to.residue}次",style: TextStyle(fontSize: 14,color: Color(0xFFB3B3B3)),),
                  SizedBox(height: 16,),
                ],
              ),
            ),

          ],
        )
    );

    final Widget body = MediaQuery.removeViewInsets(
      removeLeft: true,
      removeTop: true,
      removeRight: true,
      removeBottom: true,
      context: context,
      child: Center(
        child: InkWell(
          onTap: (){
            Get.back();
          },
          child: SizedBox(
            width: Get.width - 50,
            height: 364 + 45,
            child: content,
          ),
        ),
      ),
    );

    return AnimatedPadding(
      padding: MediaQuery.of(context).viewInsets,
      duration: const Duration(milliseconds: 120),
      curve: Curves.easeInCubic, // easeOutQuad
      child: body,
    );
  }
}
